from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

# 使用ollama部署的deepseek来兼容OpenAI的方案
llm = ChatOpenAI(
    base_url="http://localhost:11434/v1/",
    api_key='ollama',
    model="deepseek-r1:1.5b",
    temperature=0.1
)

prompt = ChatPromptTemplate.from_messages([
    ("system", "你是世界级的技术专家"),
    ("user", "{input}"),
])

chain = prompt | llm

result = chain.invoke({"input": "请介绍langchain的基本概念"})
print(result)

